package com.example.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.admin.entity.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
    @Select("SELECT COUNT(*) FROM sys_user_role WHERE role_id = #{roleId}")
    Integer selectCountByRoleId(Long roleId);
    
    @Select("SELECT u.* FROM sys_user u " +
            "LEFT JOIN sys_user_role ur ON u.id = ur.user_id " +
            "WHERE ur.role_id = #{roleId}")
    IPage<SysUser> selectPageByRoleId(Page<SysUser> page, @Param("roleId") Long roleId);
} 